package com.ymt.bpm.web.rest.remind;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ymt.bpm.dao.remind.PNotifyMapper;
import com.ymt.bpm.model.PNotify;
import com.ymt.util.DateUtil;

@RestController
@RequestMapping("/notify")
public class TestMessageResource {
	
	@Autowired
	private PNotifyMapper nDao;
	
	@GetMapping(value="/addtask")
	public String addtask(@RequestParam("String")String type,
			@RequestParam("String")String ttype){
		
		PNotify notify = new PNotify();
    	notify.setId("M-"+UUID.randomUUID());
    	notify.setPiEid("e255797f-d7df-11e6-924d-3010b3502d72");
    	notify.setTiId("16e21f72-d7e1-11e6-924d-3010b3502d72");
    	notify.setTitle("");
    	notify.setContent("");
    	Date endDate = DateUtil.getGMTDate();
    	long time = endDate.getTime();
    	time += 180000;
    	notify.setCreateTime(endDate);
    	notify.setExpireTime(new Date(time));
    	notify.setScheduleTime(DateUtil.getGMTDate());
    	notify.setType("0");
    	notify.settType("1");
    	if (type!=null) {
    		notify.setType(type);
		}
    	if (ttype!=null) {
    		notify.settType(ttype);
		}
    	notify.setStatus("0");
    	notify.setDestination("fusemailtest@163.com");
    	notify.setSender("liuhailong");
    	notify.setSenderName("刘海龙");
    	notify.setReceiver("yangbo");
    	notify.setReceiverName("杨波");
    	notify.setReadUrl("/handletask.action?tiid=16e21f72-d7e1-11e6-924d-3010b3502d72");
    	nDao.insert(notify);
    	
		return "Success";
	}
	
	@GetMapping(value="/addpi")
	public String addpi(@RequestParam("String")String type,
			@RequestParam("String")String ttype){
		
		PNotify notify = new PNotify();
    	notify.setId("M-"+UUID.randomUUID());
    	notify.setPiEid("e255797f-d7df-11e6-924d-3010b3502d72");
    	notify.setTiId("16e21f72-d7e1-11e6-924d-3010b3502d72");
    	notify.setTitle("");
    	notify.setContent("");
    	Date endDate = DateUtil.getGMTDate();
    	long time = endDate.getTime();
    	time += 180000;
    	notify.setCreateTime(endDate);
    	notify.setExpireTime(new Date(time));
    	notify.setScheduleTime(DateUtil.getGMTDate());
    	notify.setType("0");
    	notify.settType("3");
    	if (type!=null) notify.setType(type);
    	if (ttype!=null) notify.settType(ttype);
    	notify.setStatus("0");
    	notify.setDestination("fusemailtest@163.com");
    	notify.setSender("liuhailong");
    	notify.setSenderName("刘海龙");
    	notify.setReceiver("yangbo");
    	notify.setReceiverName("杨波");
    	notify.setReadUrl("/view.action?piEid=e255797f-d7df-11e6-924d-3010b3502d72");
    	nDao.insert(notify);
    	
		return "Success";
	}
	
}
